/**
  * Scala中apply的用法
  * https://www.cnblogs.com/ayning/p/5946254.html
  */

class applyTest(var x: Int, var y: Int, var z: Int) {

  def apply(x: Int, y: Int) = {
    println("I am apply x: Int, y: Int")
    " return I am apply x: Int, y: Int"
  }

  def apply(x: Int) :String= {
    println("I am apply x:Int")
    " return I am apply x:Int"
  }

  this (x, y)

  this (x)

  def speak(): String = {
    "I am spark  " + "  x==>" + x + "  y==>" + y + "  z==>" + z
  }
}

object applyTest extends App {

  //  val result = new applyTest(1, 2, 3).speak()
  //
  //  println(result)

  (x:Int) => x + 1
  val f = (x:Int) => x + 1
  println(f(1).toString)
}

